package com.bc004346.travelus.fragment;

import android.annotation.SuppressLint;
import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Button;
import android.widget.Toast;

import com.bc004346.travelus.R;
import com.bc004346.travelus.services.TripMeService;

import static com.bc004346.travelus.utility.Utility.password;
import static com.bc004346.travelus.utility.Utility.seniority;
import static com.bc004346.travelus.utility.Utility.username;

/**
 * Created by Renats on 12/4/2014.
 * manual trip me start fragment
 */
public class TripMeManualStartFragment extends Fragment {

    @Nullable
    @Override
    public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
        @SuppressLint("InflateParams")
        View v = inflater.inflate(R.layout.fragment_trip_me_manual_start, null);
        Button button = (Button) v.findViewById(R.id.button);
        button.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View view) {

                Intent i = new Intent(getActivity(), TripMeService.class);
                i.putExtra(TripMeService.EXTRA_USER, username);
                i.putExtra(TripMeService.EXTRA_PASSWORD, password);
                i.putExtra(TripMeService.EXTRA_SENIORITY, seniority);
                i.putExtra(TripMeService.EXTRA_SCHEDULED_SEARCH, false);
                getActivity().startService(i);
                Toast.makeText(getActivity(), "Watch out for notification with day trip options", Toast.LENGTH_LONG).show();
                getActivity().finish();
            }
        });
        return v;
    }
}
